package vivek.project.pocketmoney.expenses.ui
{
	import flash.events.Event;
	
	import mx.containers.Form;

	public class PMForm extends Form
	{
		[Bindable]
		public var formIsValid:Boolean=false;

		public function PMForm()
		{
			super();
		}

		public function validate(event:Event):Boolean
		{
			//trace(form.childDescriptors.length); 
			var values:Object=new Object();
			// get form items
			var formItems:Object=this.getChildren();
			// loop items and add values
			var isItemValid:Boolean=false;
			formIsValid=true;
			for (var i:int=0; i < formItems.length; i++)
			{
				// formItem
				try
				{
					var formItem:Object=formItems[i].getChildren();
					if (formItem[0].includeInLayout)
					{
						isItemValid=formItem[0].validateIt(event);
						trace(formItem[0].toString() + "|" + isItemValid.toString())
						formIsValid=formIsValid && isItemValid;
					}
				}
				catch (error:ReferenceError)
				{
					trace(error.message);
				}
			}
			return formIsValid;
		}
	}
}